#ifndef _HTTPCOOKIE_HPP_
#define _HTTPCOOKIE_HPP_

#include "jhdefs.hpp"
#include "net/NameValueCollection.hpp"

NET_NAMESPACE_BEGIN

class CHTTPCookie
{
public:
	CHTTPCookie();
	explicit CHTTPCookie(const std::string& name);
	explicit CHTTPCookie(const CNameValueCollection& nvc);

	CHTTPCookie(const std::string& name, const std::string& value);
	CHTTPCookie(const CHTTPCookie& cookie);
	~CHTTPCookie();
	CHTTPCookie& operator = (const CHTTPCookie& cookie);

	void setVersion(int version);
	int getVersion() const;

	void setName(const std::string& name);
	const std::string& getName() const;

	void setValue(const std::string& value);
	const std::string& getValue() const;

	void setComment(const std::string& comment);
	const std::string& getComment() const;

	void setDomain(const std::string& domain);
	const std::string& getDomain() const;

	void setPath(const std::string& path);
	const std::string& getPath() const;

	void setPriority(const std::string& priority);
	const std::string& getPriority() const;

	void setSecure(bool secure);
	bool getSecure() const;

	void setMaxAge(int maxAge);
	int getMaxAge() const;

	void setHttpOnly(bool flag = true);
	bool getHttpOnly() const;

	std::string toString() const;
	static std::string escape(const std::string& str);
	static std::string unescape(const std::string& str);

private:
	int         m_version;
	std::string m_name;
	std::string m_value;
	std::string m_comment;
	std::string m_domain;
	std::string m_path;
	std::string m_priority;
	bool        m_secure;
	int         m_maxAge;
	bool        m_httpOnly;
};

NET_NAMESPACE_END

#endif
